<?php
/**
 * Created by PhpStorm.
 * User: xutao
 * Date: 2018/8/8
 * Time: 13:45
 */
namespace app\index\controller;
use app\common\model\TravelsModel;
use qqconnect\QC;
use think\Session;

class Travels extends Base
{
    //游记列表
    public function get_travels()
    {
        if (\request()->isPost()) {
            if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
            $page = input('page')?input('page'):1;
            $start = $page == 1?0:($page-1)*10;
            $count = TravelsModel::where('member_id',Session::get('member')['id'])->count();
            $re = TravelsModel::alias('t')->join('think_member m', 't.member_id = m.id')->where('t.member_id', Session::get('member')['id'])->field('t.id,m.nickname,t.create_time,t.travel_model,t.is_show,t.address')->limit($start,10)->select();
            return json(['code' => 200, 'data' => $re,'count'=>$count, 'msg' => '获取成功']);
        } else {
            return json(['code' => 0, 'data' => '', 'msg' => '非法请求']);
        }
    }

    //游记删除
    public function del_travels()
    {
        if (\request()->isPost()) {
            if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
            $id = input('id');
            $re = TravelsModel::del($id);
            if ($re) {
                return \json(['code' => 200, 'data' => '', 'msg' => '删除成功']);
            } else {
                return \json(['code' => 1, 'data' => '', 'msg' => '删除失败']);
            }
        } else {
            return \json(['code' => 0, 'data' => '', 'msg' => '非法请求']);
        }
    }

    //获取游记的详细资料
    public function get_travel_data()
    {
        if (\request()->isPost()) {
            if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
            $id = input('id');
            $data = TravelsModel::get($id);
            if ($data) {
                return \json(['code' => 200, 'data' => $data, 'msg' => '获取成功']);
            } else {
                return \json(['code' => 1, 'data' => '', 'msg' => '获取失败']);
            }
        } else {
            return \json(['code' => 0, 'data' => '', 'msg' => '非法请求']);
        }
    }

    //全部游记列表
    public function get_travels_all()
    {
        if (request()->isPost()) {
            if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
            $page = input('page')?input('page'):1;
            $start = $page == 1?0:($page-1)*10;
            //类型
            //1 为自由行  2为跟团游
            $where = [];
            if (input('travel_model')) {
                $where['travel_model'] = input('travel_model');
            }

            $count = TravelsModel::where($where)->count();
            $re = TravelsModel::where($where)->limit($start,10)->select();
            return json(['code' => 200, 'data' => $re,'count'=>$count, 'msg' => '获取成功']);
        } else {
            return \json(['code' => 0, 'data' => '', 'msg' => '非法请求']);
        }
    }
    
    //游记预览
    public function travel_preview(){
        return \json(['code'=>200,'data'=>input('post.'),'msg'=>'ok']);
    }

    //游记添加
    public function travel_add()
    {
        if (!request()->isPost()) return json(['code' => 0, 'data' => '', 'msg' => '非法请求']);
       if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
//            $data = '{
//                "cover_src": "",
//                "title": "游记测试1",
//                "start_date": "2018-08-07",
//                "end_date": "2018-08-09",
//                "address": [
//                        {
//                            "country": "中国",
//                            "province": "四川",
//                            "city": "成都"
//                        },
//                        {
//                            "country": "中国",
//                            "province": "四川",
//                            "city": "绵阳"
//                        }
//                    ],
//                "travel_model": 1,
//                "relationship": "1",
//                "start_message": "",
//                "info": {
//                    "start_traffic": "1",
//                    "start_address": "chengdu ",
//                    "start_purchase_date": "2018-08-09",
//                    "start_purchase_type": "1",
//                    "start_operate": "1",
//                    "strat_evaluate": "1",
//                    "end_traffic": "2",
//                    "end_address": "1",
//                    "end_purchase_date": "2018-08-07",
//                    "end_purchase_type": "1",
//                    "end_operate": "1",
//                    "end_evaluate": "1",
//                    "accommodation": [
//                        {
//                            "hotel_name": "酒店1",
//                            "order_channel": "1",
//                            "day_price": "0.00",
//                            "hotel_evaluate": "1",
//                            "score": 0
//                        },
//                        {
//                            "hotel_name": "酒店2",
//                            "order_channel": "2",
//                        "day_price": "0.00",
//                        "hotel_evaluate": "2",
//                        "score": 0
//                    }
//                ],
//                "recommend": [
//                    {
//                        "title": "推荐1",
//                        "reason": "12"
//                    },
//                    {
//                        "title": "推荐2",
//                        "reason": "32"
//                    }
//                ],
//                "chuxin_type": "2",
//                "price": "0.00",
//                "hertz": "",
//                "bus_card": "0",
//                "mass_scale": "",
//                "consumption_day": "0.00",
//                "guide_score": 0,
//                "zhusu_score": 0,
//                "trip_score": 0,
//                "product_code": "",
//                "product_name": "",
//                "travel_agency": "",
//                "orther": "",
//                "is_drivers":0,
//                "lxs_model":0,
//                "lxs_money":0.00,
//            },
//            "travel_records": [
//                {
//                    "date": "2018-08-06",
//                    "spot": "1",
//                    "img": [
//                        {
//                            "src": "src1",
//                            "msg": "",
//                            "photo_equipment": "2"
//                        },
//                        {
//                            "src": "src3",
//                            "msg": "",
//                            "photo_equipment": "1"
//                        }
//                    ],
//                    "is_festival": "0",
//                    "sketch": ""
//                },
//                {
//                    "date": "2018-08-07",
//                    "spot": "1",
//                    "img": [
//                        {
//                            "src": "src1",
//                            "msg": "",
//                            "photo_equipment": "1"
//                        },
//                        {
//                            "src": "src2",
//                            "msg": "",
//                            "photo_equipment": "2"
//                        }
//                    ],
//                    "is_festival": "1",
//                    "sketch": ""
//                }
//            ],
//            "preparation_img": [
//                "src1",
//                "src2"
//            ],
//            "end_message": ""
//}';
//        $data = json_decode($data,true);
//        $data = 'a:12:{s:9:"cover_src";s:60:"public\uploads\20180816\37fd964ddbe8f290056b94a77bda4fab.jpg";s:5:"title";s:18:"这是测试内容";s:10:"start_date";s:10:"2018-08-16";s:8:"end_date";s:10:"2018-08-16";s:7:"address";a:1:{i:0;a:5:{s:5:"value";s:20:"中国-北京-东城";s:7:"country";s:6:"中国";s:7:"prvince";s:6:"北京";s:4:"city";s:6:"东城";s:3:"num";i:0;}}s:12:"travel_model";s:1:"2";s:12:"relationship";s:1:"1";s:13:"start_message";s:18:"这是测试内容";s:4:"info";a:24:{s:13:"start_traffic";s:0:"";s:19:"start_purchase_date";s:0:"";s:19:"start_purchase_type";s:0:"";s:13:"start_operate";s:0:"";s:14:"strat_evaluate";s:0:"";s:11:"end_traffic";s:0:"";s:11:"end_address";s:0:"";s:17:"end_purchase_date";s:0:"";s:17:"end_purchase_type";s:0:"";s:11:"end_operate";s:0:"";s:12:"end_evaluate";s:0:"";s:13:"accommodation";a:1:{i:0;a:5:{s:10:"hotel_name";s:0:"";s:13:"order_channel";s:0:"";s:9:"day_price";s:0:"";s:14:"hotel_evaluate";i:0;s:5:"score";i:0;}}s:9:"recommend";a:1:{i:0;a:2:{s:5:"title";s:18:"这是测试内容";s:6:"reason";s:18:"这是测试内容";}}s:11:"chuxin_type";s:1:"2";s:5:"price";s:3:"100";s:5:"hertz";s:0:"";s:10:"is_drivers";s:0:"";s:8:"bus_card";s:1:"1";s:10:"mass_scale";s:0:"";s:11:"guide_score";i:5;s:11:"zhusu_score";i:5;s:13:"travel_agency";s:18:"这是测试内容";s:9:"lxs_model";s:1:"2";s:9:"lxs_money";s:3:"100";}s:14:"travel_records";a:1:{i:0;a:5:{s:4:"date";s:10:"2018-08-16";s:4:"spot";s:18:"这是测试内容";s:11:"is_festival";s:1:"0";s:6:"sketch";s:18:"这是测试内容";s:3:"img";a:1:{i:0;a:5:{s:3:"src";s:60:"public\uploads\20180816\f18edc6e5486bc6485baa312d71e0434.jpg";s:3:"msg";s:18:"这是测试内容";s:3:"img";s:63:"blob:http://localhost:8080/31202565-f069-402f-be5e-0a935247f4e8";s:15:"photo_equipment";s:0:"";s:5:"equip";s:1:"1";}}}}s:15:"preparation_img";a:1:{i:0;s:60:"public\uploads\20180816\6550f524852231b39db0e54799ddaccf.jpg";}s:11:"end_message";s:18:"这是测试内容";}';
//        $data = 'a:12:{s:9:"cover_src";s:60:"public\uploads\20180816\b870c451adbfa488266967dc2061b004.jpg";s:5:"title";s:18:"这是测试内容";s:10:"start_date";s:10:"2018-08-16";s:8:"end_date";s:10:"2018-08-16";s:7:"address";a:1:{i:0;a:5:{s:5:"value";s:20:"中国-北京-东城";s:7:"country";s:6:"中国";s:7:"prvince";s:6:"北京";s:4:"city";s:6:"东城";s:3:"num";i:0;}}s:12:"travel_model";s:1:"2";s:12:"relationship";s:1:"1";s:13:"start_message";s:18:"这是测试内容";s:4:"info";a:24:{s:13:"start_traffic";s:0:"";s:19:"start_purchase_date";s:0:"";s:19:"start_purchase_type";s:0:"";s:13:"start_operate";s:0:"";s:14:"strat_evaluate";s:0:"";s:11:"end_traffic";s:0:"";s:11:"end_address";s:0:"";s:17:"end_purchase_date";s:0:"";s:17:"end_purchase_type";s:0:"";s:11:"end_operate";s:0:"";s:12:"end_evaluate";s:0:"";s:13:"accommodation";a:1:{i:0;a:5:{s:10:"hotel_name";s:0:"";s:13:"order_channel";s:0:"";s:9:"day_price";s:0:"";s:14:"hotel_evaluate";i:0;s:5:"score";i:0;}}s:9:"recommend";a:1:{i:0;a:2:{s:5:"title";s:18:"这是测试内容";s:6:"reason";s:18:"这是测试内容";}}s:11:"chuxin_type";s:1:"2";s:5:"price";s:3:"100";s:5:"hertz";s:0:"";s:10:"is_drivers";s:0:"";s:8:"bus_card";s:1:"1";s:10:"mass_scale";s:0:"";s:11:"guide_score";i:5;s:11:"zhusu_score";i:5;s:13:"travel_agency";s:18:"这是测试内容";s:9:"lxs_model";s:1:"4";s:9:"lxs_money";s:3:"100";}s:14:"travel_records";a:1:{i:0;a:5:{s:4:"date";s:10:"2018-08-16";s:4:"spot";s:18:"这是测试内容";s:11:"is_festival";s:1:"1";s:6:"sketch";s:18:"这是测试内容";s:3:"img";a:1:{i:0;a:5:{s:3:"src";s:60:"public\uploads\20180816\2d10e69ee0c7c64c46a2f3fdfcc5e7d6.jpg";s:3:"msg";s:18:"这是测试内容";s:3:"img";s:63:"blob:http://localhost:8080/5a8d1c31-3fd8-4af2-97f1-9aef581085c5";s:15:"photo_equipment";s:0:"";s:5:"equip";s:1:"1";}}}}s:15:"preparation_img";a:1:{i:0;s:60:"public\uploads\20180816\472102fea1940aa057b83e29480988f9.jpg";}s:11:"end_message";s:18:"这是测试内容";}';
//
// $data = 'a:12:{s:9:"cover_src";s:60:"public\uploads\20180817\738e20ec4b767f4b25d69f66ad8fb5ee.jpg";s:5:"title";s:12:"游记标题";s:10:"start_date";s:10:"2018-08-17";s:8:"end_date";s:10:"2018-08-18";s:7:"address";a:2:{i:0;a:5:{s:5:"value";s:20:"中国-北京-东城";s:7:"country";s:6:"中国";s:7:"prvince";s:6:"北京";s:4:"city";s:6:"东城";s:3:"num";i:0;}i:1;a:6:{s:5:"value";s:29:"中国-内蒙古-呼和浩特";s:7:"country";s:6:"中国";s:8:"province";s:0:"";s:4:"city";s:12:"呼和浩特";s:3:"num";i:1;s:7:"prvince";s:9:"内蒙古";}}s:12:"travel_model";s:1:"2";s:12:"relationship";s:1:"1";s:13:"start_message";s:12:"开篇寄语";s:4:"info";a:24:{s:13:"start_traffic";s:0:"";s:19:"start_purchase_date";s:0:"";s:19:"start_purchase_type";s:0:"";s:13:"start_operate";s:0:"";s:14:"strat_evaluate";s:0:"";s:11:"end_traffic";s:0:"";s:11:"end_address";s:0:"";s:17:"end_purchase_date";s:0:"";s:17:"end_purchase_type";s:0:"";s:11:"end_operate";s:0:"";s:12:"end_evaluate";s:0:"";s:13:"accommodation";a:1:{i:0;a:5:{s:10:"hotel_name";s:0:"";s:13:"order_channel";s:0:"";s:9:"day_price";s:0:"";s:14:"hotel_evaluate";i:0;s:5:"score";i:0;}}s:9:"recommend";a:2:{i:0;a:2:{s:5:"title";s:10:"推荐名1";s:6:"reason";s:12:"推荐理由";}i:1;a:2:{s:5:"title";s:10:"推荐名2";s:6:"reason";s:12:"推荐理由";}}s:11:"chuxin_type";s:1:"2";s:5:"price";s:3:"799";s:5:"hertz";s:0:"";s:10:"is_drivers";s:0:"";s:8:"bus_card";s:1:"1";s:10:"mass_scale";s:0:"";s:11:"guide_score";i:5;s:11:"zhusu_score";i:4;s:13:"travel_agency";s:15:"旅行社名称";s:9:"lxs_model";s:1:"1";s:9:"lxs_money";s:3:"699";}s:14:"travel_records";a:2:{i:0;a:5:{s:4:"date";s:10:"2018-08-17";s:4:"spot";s:6:"故宫";s:11:"is_festival";s:1:"0";s:6:"sketch";s:12:"当日描述";s:3:"img";a:2:{i:0;a:4:{s:3:"src";s:60:"public\uploads\20180817\2c2bfb13131260f3dee7a8b46a462fa9.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/de8023af-415d-4148-adb0-7a995ad537a4";s:15:"photo_equipment";s:1:"1";}i:1;a:4:{s:3:"src";s:60:"public\uploads\20180817\3229addb0eefe0589f29edba5d274d98.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/f7062c5d-4b84-40c3-91bd-de19d69feef6";s:15:"photo_equipment";s:1:"2";}}}i:1;a:5:{s:4:"date";s:10:"2018-08-18";s:4:"spot";s:21:"呼伦贝尔大草原";s:11:"is_festival";s:1:"1";s:6:"sketch";s:12:"当日描述";s:3:"img";a:1:{i:0;a:4:{s:3:"src";s:60:"public\uploads\20180817\95e917d36b191a0aa2b1edd03d41bbd5.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/2d67ae94-29d1-40df-ab59-0561d8d6eaf0";s:15:"photo_equipment";s:1:"2";}}}}s:15:"preparation_img";a:1:{i:0;s:60:"public\uploads\20180817\35b01673c90adc69abac050591911bdc.jpg";}s:11:"end_message";s:12:"结束寄语";}';

        $data = input('post.');

       $re = TravelsModel::add($data);
       if($re){
           return json(['code' => 200, 'data' => '', 'msg' => '添加成功']);
       }else{
           return json(['code' => 0, 'data' => $re, 'msg' => '添加失败']);
       }
    }
    public function add_test(){
                    $data = '{
                "cover_src": "",
                "title": "游记测试1",
                "start_date": "2018-08-07",
                "end_date": "2018-08-09",
                "address": [
                        {
                            "country": "中国",
                            "province": "四川",
                            "city": "成都"
                        },
                        {
                            "country": "中国",
                            "province": "四川",
                            "city": "绵阳"
                        }
                    ],
                "travel_model": 1,
                "relationship": "1",
                "start_message": "",
                "info": {
                    "start_traffic": "1",
                    "start_address": "chengdu ",
                    "start_purchase_date": "2018-08-09",
                    "start_purchase_type": "1",
                    "start_operate": "1",
                    "strat_evaluate": "1",
                    "end_traffic": "2",
                    "end_address": "1",
                    "end_purchase_date": "2018-08-07",
                    "end_purchase_type": "1",
                    "end_operate": "1",
                    "end_evaluate": "1",
                    "accommodation": [
                        {
                            "hotel_name": "酒店1",
                            "order_channel": "1",
                            "day_price": "0.00",
                            "hotel_evaluate": "1",
                            "score": 0
                        },
                        {
                            "hotel_name": "酒店2",
                            "order_channel": "2",
                        "day_price": "0.00",
                        "hotel_evaluate": "2",
                        "score": 0
                    }
                ],
                "recommend": [
                    {
                        "title": "推荐1",
                        "reason": "12"
                    },
                    {
                        "title": "推荐2",
                        "reason": "32"
                    }
                ],
                "chuxin_type": "2",
                "price": "0.00",
                "hertz": "",
                "bus_card": "0",
                "mass_scale": "",
                "consumption_day": "0.00",
                "guide_score": 0,
                "zhusu_score": 0,
                "trip_score": 0,
                "product_code": "",
                "product_name": "",
                "travel_agency": "",
                "orther": "",
                "is_drivers":0,
                "lxs_model":0,
                "lxs_money":0.00,
            },
            "travel_records": [
                {
                    "date": "2018-08-06",
                    "spot": "1",
                    "img": [
                        {
                            "src": "src1",
                            "msg": "",
                            "photo_equipment": "2"
                        },
                        {
                            "src": "src3",
                            "msg": "",
                            "photo_equipment": "1"
                        }
                    ],
                    "is_festival": "0",
                    "sketch": ""
                },
                {
                    "date": "2018-08-07",
                    "spot": "1",
                    "img": [
                        {
                            "src": "src1",
                            "msg": "",
                            "photo_equipment": "1"
                        },
                        {
                            "src": "src2",
                            "msg": "",
                            "photo_equipment": "2"
                        }
                    ],
                    "is_festival": "1",
                    "sketch": ""
                }
            ],
            "preparation_img": [
                "src1",
                "src2"
            ],
            "end_message": ""
}';

        $data = json_decode($data,true);
        return json($data);

    }
    public function up_test(){
        $data = '{
                "id":9,
                "cover_src": "",
                "title": "游记测试1",
                "start_date": "2018-08-07",
                "end_date": "2018-08-09",
                "address": [
                        {
                            "country": "中国",
                            "province": "四川",
                            "city": "成都"
                        },
                        {
                            "country": "中国",
                            "province": "四川",
                            "city": "绵阳"
                        }
                    ],
                "travel_model": 1,
                "relationship": "1",
                "start_message": "",
                "info": {
                    "start_traffic": "1",
                    "start_address": "chengdu ",
                    "start_purchase_date": "2018-08-09",
                    "start_purchase_type": "1",
                    "start_operate": "1",
                    "strat_evaluate": "1",
                    "end_traffic": "2",
                    "end_address": "1",
                    "end_purchase_date": "2018-08-07",
                    "end_purchase_type": "1",
                    "end_operate": "1",
                    "end_evaluate": "1",
                    "accommodation": [
                        {
                            "hotel_name": "酒店1",
                            "order_channel": "1",
                            "day_price": "0.00",
                            "hotel_evaluate": "1",
                            "score": 0
                        },
                        {
                            "hotel_name": "酒店2",
                            "order_channel": "2",
                        "day_price": "0.00",
                        "hotel_evaluate": "2",
                        "score": 0
                    }
                ],
                "recommend": [
                    {
                        "title": "推荐1",
                        "reason": "12"
                    },
                    {
                        "title": "推荐2",
                        "reason": "32"
                    }
                ],
                "chuxin_type": "2",
                "price": "0.00",
                "hertz": "",
                "bus_card": "0",
                "mass_scale": "",
                "consumption_day": "0.00",
                "guide_score": 0,
                "zhusu_score": 0,
                "trip_score": 0,
                "product_code": "",
                "product_name": "",
                "travel_agency": "",
                "orther": "",
                "is_drivers":0,
                "lxs_model":0,
                "lxs_money":0.00,
            },
            "travel_records": [
                {
                    "date": "2018-08-06",
                    "spot": "1",
                    "img": [
                        {
                            "src": "src1",
                            "msg": "",
                            "photo_equipment": "2"
                        },
                        {
                            "src": "src3",
                            "msg": "",
                            "photo_equipment": "1"
                        }
                    ],
                    "is_festival": "0",
                    "sketch": ""
                },
                {
                    "date": "2018-08-07",
                    "spot": "1",
                    "img": [
                        {
                            "src": "src1",
                            "msg": "",
                            "photo_equipment": "1"
                        },
                        {
                            "src": "src2",
                            "msg": "",
                            "photo_equipment": "2"
                        }
                    ],
                    "is_festival": "1",
                    "sketch": ""
                }
            ],
            "preparation_img": [
                "src1",
                "src2"
            ],
            "end_message": ""
}';

        $data = json_decode($data, true);
        return json($data);
    }

    //跟新游记
    public function travel_edit(){

//        $data = '{
//                "id":9,
//                "cover_src": "",
//                "title": "游记测试1",
//                "start_date": "2018-08-07",
//                "end_date": "2018-08-09",
//                "address": [
//                        {
//                            "country": "中国",
//                            "province": "四川",
//                            "city": "成都"
//                        },
//                        {
//                            "country": "中国",
//                            "province": "四川",
//                            "city": "绵阳"
//                        }
//                    ],
//                "travel_model": 1,
//                "relationship": "1",
//                "start_message": "",
//                "info": {
//                    "start_traffic": "1",
//                    "start_address": "chengdu ",
//                    "start_purchase_date": "2018-08-09",
//                    "start_purchase_type": "1",
//                    "start_operate": "1",
//                    "strat_evaluate": "1",
//                    "end_traffic": "2",
//                    "end_address": "1",
//                    "end_purchase_date": "2018-08-07",
//                    "end_purchase_type": "1",
//                    "end_operate": "1",
//                    "end_evaluate": "1",
//                    "accommodation": [
//                        {
//                            "hotel_name": "酒店1",
//                            "order_channel": "1",
//                            "day_price": "0.00",
//                            "hotel_evaluate": "1",
//                            "score": 0
//                        },
//                        {
//                            "hotel_name": "酒店2",
//                            "order_channel": "2",
//                        "day_price": "0.00",
//                        "hotel_evaluate": "2",
//                        "score": 0
//                    }
//                ],
//                "recommend": [
//                    {
//                        "title": "推荐1",
//                        "reason": "12"
//                    },
//                    {
//                        "title": "推荐2",
//                        "reason": "32"
//                    }
//                ],
//                "chuxin_type": "2",
//                "price": "0.00",
//                "hertz": "",
//                "bus_card": "0",
//                "mass_scale": "",
//                "consumption_day": "0.00",
//                "guide_score": 0,
//                "zhusu_score": 0,
//                "trip_score": 0,
//                "product_code": "",
//                "product_name": "",
//                "travel_agency": "",
//                "orther": "",
//                "lxs_model":0,
//                "lxs_money":0.00,
//        "is_drivers":0
//            },
//            "travel_records": [
//                {
//                    "date": "2018-08-06",
//                    "spot": "1",
//                    "img": [
//                        {
//                            "src": "src1",
//                            "msg": "",
//                            "photo_equipment": "2"
//                        },
//                        {
//                            "src": "src3",
//                            "msg": "",
//                            "photo_equipment": "1"
//                        }
//                    ],
//                    "is_festival": "0",
//                    "sketch": ""
//                },
//                {
//                    "date": "2018-08-07",
//                    "spot": "1",
//                    "img": [
//                        {
//                            "src": "src1",
//                            "msg": "",
//                            "photo_equipment": "1"
//                        },
//                        {
//                            "src": "src2",
//                            "msg": "",
//                            "photo_equipment": "2"
//                        }
//                    ],
//                    "is_festival": "1",
//                    "sketch": ""
//                }
//            ],
//            "preparation_img": [
//                "src1",
//                "src2"
//            ],
//            "end_message": ""
//}';
//        $data = json_decode($data, true);
        if(request()->isPost()){
            if (!Session::get('member')) return json(['code' => 9, 'data' => '', 'msg' => '请登录']);
            $data = input('post.');
            if(!$data) return json(['code'=>1,'data'=>'','msg'=>'参数为空']);
            $re = TravelsModel::edit($data);

            if($re){
                return json(['code'=>200,'data'=>'','msg'=>'更新成功']);
            }else{
                return json(['code'=>0,'data'=>'','msg'=>'更新失败']);
            }
        }else{
            return json(['code'=>0,'data'=>'','msg'=>'非法请求']);
        }

    }
    public function test(){
        $data = 'a:12:{s:9:"cover_src";s:60:"public\uploads\20180817\738e20ec4b767f4b25d69f66ad8fb5ee.jpg";s:5:"title";s:12:"游记标题";s:10:"start_date";s:10:"2018-08-17";s:8:"end_date";s:10:"2018-08-18";s:7:"address";a:2:{i:0;a:5:{s:5:"value";s:20:"中国-北京-东城";s:7:"country";s:6:"中国";s:7:"prvince";s:6:"北京";s:4:"city";s:6:"东城";s:3:"num";i:0;}i:1;a:6:{s:5:"value";s:29:"中国-内蒙古-呼和浩特";s:7:"country";s:6:"中国";s:8:"province";s:0:"";s:4:"city";s:12:"呼和浩特";s:3:"num";i:1;s:7:"prvince";s:9:"内蒙古";}}s:12:"travel_model";s:1:"2";s:12:"relationship";s:1:"1";s:13:"start_message";s:12:"开篇寄语";s:4:"info";a:24:{s:13:"start_traffic";s:0:"";s:19:"start_purchase_date";s:0:"";s:19:"start_purchase_type";s:0:"";s:13:"start_operate";s:0:"";s:14:"strat_evaluate";s:0:"";s:11:"end_traffic";s:0:"";s:11:"end_address";s:0:"";s:17:"end_purchase_date";s:0:"";s:17:"end_purchase_type";s:0:"";s:11:"end_operate";s:0:"";s:12:"end_evaluate";s:0:"";s:13:"accommodation";a:1:{i:0;a:5:{s:10:"hotel_name";s:0:"";s:13:"order_channel";s:0:"";s:9:"day_price";s:0:"";s:14:"hotel_evaluate";i:0;s:5:"score";i:0;}}s:9:"recommend";a:2:{i:0;a:2:{s:5:"title";s:10:"推荐名1";s:6:"reason";s:12:"推荐理由";}i:1;a:2:{s:5:"title";s:10:"推荐名2";s:6:"reason";s:12:"推荐理由";}}s:11:"chuxin_type";s:1:"2";s:5:"price";s:3:"799";s:5:"hertz";s:0:"";s:10:"is_drivers";s:0:"";s:8:"bus_card";s:1:"1";s:10:"mass_scale";s:0:"";s:11:"guide_score";i:5;s:11:"zhusu_score";i:4;s:13:"travel_agency";s:15:"旅行社名称";s:9:"lxs_model";s:1:"1";s:9:"lxs_money";s:3:"699";}s:14:"travel_records";a:2:{i:0;a:5:{s:4:"date";s:10:"2018-08-17";s:4:"spot";s:6:"故宫";s:11:"is_festival";s:1:"0";s:6:"sketch";s:12:"当日描述";s:3:"img";a:2:{i:0;a:4:{s:3:"src";s:60:"public\uploads\20180817\2c2bfb13131260f3dee7a8b46a462fa9.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/de8023af-415d-4148-adb0-7a995ad537a4";s:15:"photo_equipment";s:1:"1";}i:1;a:4:{s:3:"src";s:60:"public\uploads\20180817\3229addb0eefe0589f29edba5d274d98.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/f7062c5d-4b84-40c3-91bd-de19d69feef6";s:15:"photo_equipment";s:1:"2";}}}i:1;a:5:{s:4:"date";s:10:"2018-08-18";s:4:"spot";s:21:"呼伦贝尔大草原";s:11:"is_festival";s:1:"1";s:6:"sketch";s:12:"当日描述";s:3:"img";a:1:{i:0;a:4:{s:3:"src";s:60:"public\uploads\20180817\95e917d36b191a0aa2b1edd03d41bbd5.jpg";s:3:"msg";s:12:"照片说明";s:3:"img";s:63:"blob:http://localhost:8080/2d67ae94-29d1-40df-ab59-0561d8d6eaf0";s:15:"photo_equipment";s:1:"2";}}}}s:15:"preparation_img";a:1:{i:0;s:60:"public\uploads\20180817\35b01673c90adc69abac050591911bdc.jpg";}s:11:"end_message";s:12:"结束寄语";}';
$data = \unserialize($data);
echo "<pre>";
print_r($data);die;
        $re = Session::get('member');
        return json(['code'=>0,'data'=>$re,'msg'=>'更新失败']);
    }
    public function testqq(){
        $qqlogin = new QC();
        $re = $qqlogin->qq_login();
        return $this->redirect($re);
    }
}